<?xml version="1.0" encoding="UTF-8"?>
<jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:ui="http://www.sun.com/web/ui">
    <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
    <f:view>
        <ui:page binding="#{PageFileUpload.page}" id="page">
            <ui:html binding="#{PageFileUpload.html}" id="html">
                <ui:head binding="#{PageFileUpload.head}" id="head">
                    <ui:link binding="#{PageFileUpload.link}" id="link" url="/resources/stylesheet.css"/>
                </ui:head>
                <ui:body binding="#{PageFileUpload.body}" id="body">
                    <ui:form binding="#{PageFileUpload.fileUploadForm}" id="fileUploadForm" enctype="multipart/form-data">
                        <table>
                            <tr>
                                <td align="center">
                                    <h:panelGrid binding="#{PageFileUpload.fileUploadGridPanel}" columns="2" id="fileUploadGridPanel"
                                        rendered="#{SessionBeanFileUpload.renderedFileUploadGridPanel}" style="text-align: center" width="100%">
                                        <ui:upload binding="#{PageFileUpload.fileUpload}" id="fileUpload"/>
                                        <h:commandButton action="#{PageFileUpload.cargarButton_action}" binding="#{PageFileUpload.cargarButton}"
                                            id="cargarButton" styleClass="button" value="CARGAR"/>
                                    </h:panelGrid>
                                    <h:panelGrid binding="#{PageFileUpload.mensajeAlertGridPanel}" id="mensajeAlertGridPanel"
                                        rendered="#{SessionBeanFileUpload.renderedMensajeAlertGridPanel}" style="text-align: center" width="100%">
                                        <ui:alert binding="#{PageFileUpload.mensajeAlert}" id="mensajeAlert"/>
                                    </h:panelGrid>
                                    <h:panelGrid binding="#{PageFileUpload.espaciadorGridPanel}" id="espaciadorGridPanel" style="text-align: center" width="100%">
                                        <h:outputText binding="#{PageFileUpload.outputText1}" id="outputText1" style="color: white" value="___________________________________________________________"/>
                                    </h:panelGrid>
                                    <ui:hiddenField binding="#{PageFileUpload.nameUploadedFileHiddenField}" id="nameUploadedFileHiddenField"/>
                                    <ui:hiddenField binding="#{PageFileUpload.invalidOperationHiddenField}" id="invalidOperationHiddenField"/>
                                </td>
                            </tr>
                        </table>
                    </ui:form>
                    <!-- javascript -->
                    <script language="JavaScript" type="text/javascript">
                        if (document.forms["fileUploadForm"]["fileUploadForm:nameUploadedFileHiddenField"].value != "") {
                            opener.document.forms["accionesForm"]["accionesForm:nameFileAttachTextField"].value = document.forms["fileUploadForm"]["fileUploadForm:nameUploadedFileHiddenField"].value;
                            opener.document.forms["accionesForm"]["accionesForm:nameFileAttachHiddenField"].value = document.forms["fileUploadForm"]["fileUploadForm:nameUploadedFileHiddenField"].value;
                            setTimeout("closePopupFileUpload()", 3000);
                        }
                        else {
                            if (document.forms["fileUploadForm"]["fileUploadForm:invalidOperationHiddenField"].value != "") {
                                setTimeout("closePopupFileUpload()", 4000);
                            }
                        }
                        function closePopupFileUpload() {
                            document.forms["fileUploadForm"]["fileUploadForm:nameUploadedFileHiddenField"].value = "";
                            document.forms["fileUploadForm"]["fileUploadForm:invalidOperationHiddenField"].value = "";
                            document.forms["fileUploadForm"].submit();
                            window.close();
                        }
                    </script>
                </ui:body>
            </ui:html>
        </ui:page>
    </f:view>
</jsp:root>